package javase.array;

import java.util.Arrays;

public class ArrayTest2 {
    public static void main(String[] args) {
        int[] arr = new int[10];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = (int) (Math.random() * 89 + 10);
        }
        System.out.println(Arrays.toString(arr));

        /*求最大值*/
        int max = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if (max < arr[i]) {
                max = arr[i];
            }
        }
        System.out.println(max);
        /*求最小值*/
        int min = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if (min > arr[i]) {
                min = arr[i];
            }
        }
        System.out.println(min);

        /*求总和*/
        int num = 0;
        for (int i = 0; i < arr.length; i++) {
            num += arr[i];
        }
        System.out.println(num);

        /*求平均值*/
        int length = arr.length;
        double average = (double) num / length;
        System.out.println(average);

        for (int i = 1; i < 10; i++) {
            for (int j = 1; j < i + 1; j++) {
                System.out.print(i + "*" + j + "=" + i * j+"\t");
            }
            System.out.println();
        }
    }
}
